WithLock
WithLock[File["path"],expr] locks the file path, evaluates expr, then releases the file.
WithLock[LocalSymbol["name"],expr] locks the local symbol name, evaluates expr, then releases the local symbol.
WithLock[var,expr] locks the shared variable var, evaluates expr, then releases the shared variable.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.